package com.hc.dfs.fragment.contact;

import java.util.ArrayList;
import java.util.HashMap;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.hc.dfs.activity.R;

/** 
 * @author 王洪胜  E-mail:  
 * @version 创建时间：2013-3-12 下午4:47:32
 * 
 * 类说明：
 *
 */
public class DeptmentFragment extends Fragment {

	private ArrayList<HashMap<String, Object>> dataList;
	private ListView list;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		System.out.println("创建fragment");
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.contact_dept_list, container, false);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		list = (ListView) getActivity().findViewById(R.id.list);
		dataList = new ArrayList<HashMap<String, Object>>();
		for(int i=0; i<10; i++){
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("icon", R.drawable.arrow);
			map.put("deptName", "大通置业"+i);
			dataList.add(map);
		}
		SimpleAdapter sa = new SimpleAdapter(getActivity(),dataList, R.layout.contact_member_item, new String[]{"icon","deptName"}, new int[]{R.id.imageView1, R.id.textView1});
		list.setAdapter(sa);
		list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// 处理点击列表条目事件
				//添加根据id查询成员的任务
				//
			}
		});
	}

	void showMembers(int deptId){
		
	}
	
	@Override
	public void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

}
